<template>
    <div class="content-container">
        <!-- 内容类型tab -->
        <div class="content-type-tabs">
            <div 
                class="content-type-tab"
                :class="{ active: contentType === 'original' }"
                @click="contentType = 'original'"
            >
                原文
            </div>
            <div 
                class="content-type-tab"
                :class="{ active: contentType === 'translated' }"
                @click="contentType = 'translated'"
            >
                译文
            </div>
            <div 
                class="content-type-tab"
                :class="{ active: contentType === 'compare' }"
                @click="contentType = 'compare'"
            >
                对照
            </div>
        </div>

        <!-- 内容列表 -->
        <div class="content-list">
            <div 
                v-for="(item, index) in contentData" 
                :key="index"
                class="content-item"
            >
                <!-- 原文 -->
                <div v-if="contentType === 'original' && item.originalText" class="content-original">
                    {{ item.originalText }}
                </div>
                
                <!-- 译文 -->
                <div v-if="contentType === 'translated' && item.translatedText" class="content-translated">
                    {{ item.translatedText }}
                </div>
                
                <!-- 对照 -->
                <div v-if="contentType === 'compare'" class="content-compare">
                    <div v-if="item.originalText" class="content-original">
                        {{ item.originalText }}
                    </div>
                    <div v-if="item.translatedText" class="content-translated">
                        {{ item.translatedText }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import type { DocsContentItem } from '@/api/bazi'

interface Props {
    contentData: DocsContentItem[]
}

defineProps<Props>()

const contentType = ref<'original' | 'translated' | 'compare'>('original')
</script>

<style scoped>
.content-container {
    margin-top: 10px;
}

/* 内容类型tab */
.content-type-tabs {
    display: inline-flex;
    gap: 0;
    margin-bottom: 16px;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 4px;
}

.content-type-tab {
    padding: 8px 20px;
    text-align: center;
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    white-space: nowrap;
}

.content-type-tab.active {
    color: #3b82f6;
    font-weight: 600;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.content-list {
    display: block;
    max-width: 100%;
    padding: 0;
}

.content-item {
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    margin-bottom: 20px;
}

.content-item:last-child {
    margin-bottom: 0;
}

.content-original {
    font-size: 16px;
    color: #1e293b;
    line-height: 2.2;
    margin-bottom: 0;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-align: justify;
    word-break: break-word;
    text-indent: 2em;
}

.content-translated {
    font-size: 16px;
    color: #1e293b;
    line-height: 2.2;
    margin-bottom: 0;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-align: justify;
    word-break: break-word;
    text-indent: 2em;
}

.content-compare {
    display: block;
}

.content-compare .content-original {
    font-size: 16px;
    color: #1e293b;
    line-height: 2.2;
    margin-bottom: 16px;
    padding-bottom: 0;
    border-bottom: none;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-align: justify;
    word-break: break-word;
    text-indent: 2em;
}

.content-compare .content-translated {
    font-size: 15px;
    color: #475569;
    line-height: 2.0;
    margin-bottom: 0;
    font-weight: 400;
    letter-spacing: 0.3px;
    text-align: justify;
    word-break: break-word;
    text-indent: 2em;
}
</style>
